package com.yang.controller;

import com.alibaba.fastjson.JSON;
import com.yang.pojo.Role;
import com.yang.pojo.User;
import com.yang.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/sys/role")
public class RoleController {
    @Autowired
    private RoleService service;
    @RequestMapping(value = "/queryAll",method = RequestMethod.GET,
            produces = "application/json;charset=utf-8")
    @ResponseBody//表示该方法的返回结果直接写入 HTTP response body 中，一般在异步获取数据时使用
    public String queryAll(){
        List<Role> list = service.queryAll();
        return JSON.toJSONString(list);
    }
}
